/*
 * @Author: your name
 * @Date: 2021-01-07 11:41:32
 * @LastEditTime: 2021-12-17 22:02:56
 * @LastEditors: 晟松
 * @Description: In User Settings Edit
 * @FilePath: \vue3-admin\src\router\index.js
 */

// 还有个createWebHashHistory
import { createRouter, createWebHistory } from "vue-router";
import globalRoutes from "./globalRoutes";
import mainRoutes from "./mainRoutes";

const router = createRouter({
    history: createWebHistory(),
    scrollBehavior: () => ({ y: 0 }),
    isAddDynamicMenuRoutes: false, // 是否已经添加动态(菜单)路由，这个属性似乎官方文档没有，在permission.js里面会进行判断和修改
    routes: globalRoutes.concat(mainRoutes),
});
// console.log(
//     "globalRoutes.concat(mainRoutes): ",
//     globalRoutes.concat(mainRoutes)
// );

export const tagViewsChange = (store) => {
    router.beforeEach((to, from, next) => {
        // console.log("to: ", to);
        store.commit("app/ADD_TAG_VIEWS", to);
        next();
    });
};

export default router;
